package javase.javase02.networkprograming;

import javax.swing.*;

/**
 * @author: Gan
 * @date 2021/4/23 0023 17:18
 * @description:
 **/
public class Client {
    public static void main(String[] args) {
        //  int n = Integer.MIN_VALUE;
        // array creation with both dimension expression and initialization is illegal

        int[] nums = {1, 4, 2, 4, 4, 2, 2};
        System.out.println(singleNumber(nums));
    }

    public static int singleNumber(int[] nums) {
        /*   int max = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] > max) {
                max = nums[i];
            }
        }*/
        int[] arr = new int[999];
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0) {
                arr[nums[i]]++;
            }
        }
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 1) {
                return i;
            }
        }
        return -1;
    }
}
